A Stack Collection is an ordered set of data items, which are accessed on a LIFO (Last-In / First-Out) basis. Each data item is passed and stored as a variant variable, using the Push and Pop methods.
Include file: CStack.inc
| Name | Description |
|---|---|
| Push | Appends a variant at the end of the collection. |
| Pop | Gets and removes the last element of the collection. |
| Count | Returns the number of elements in the collection. |
| Clear | Removes all the elements in the collection. |
Appends a variant at the end of the collection.
FUNCTION Push (BYREF cv AS CVAR) AS HRESULT
Returns S_OK on success, or an error HRESULT on failure. Error DISP_E_ARRAYISLOCKED: The array is locked.
#INCLUDE ONCE "Afx/CStack.inc"
using Afx
DIM pStack AS CStack
pStack.Push "String 1"
pStack.Push "String 2"
DIM cv AS CVAR
cv = pStack.Pop
PRINT cv
cv = pStack.Pop
PRINT cv
' --or--
PRINT pStack.Pop
PRINT pStack.Pop
Gets and removes the last element of the collection.
FUNCTION Pop () AS CVAR
A Variant. If there are no elements to pop, the returned variant will be empty.
Returns the number of elements in the collection.
FUNCTION Count () AS UINT
Returns the number of elements in the collection.
FUNCTION Clear () AS HRESULT
Returns S_OK on success, or an error HRESULT on failure.